home *** CD-ROM | disk | FTP | other *** search
- /* this script discompose a .TAP file in the corresponding .header and */
- /* .bytes files, and place them in the selected directory */
-
- /* check if the emulator is present */
- address command
-
- if ~show(ports,ZXAM_REXX) then do
- requestchoice '>nil: title "ZXAM Script error..." body "I can't find the emulator's port!!" gadgets "AARGH!"'
- exit
- end
-
- /* old window parameters */
- oldname=zxamactname()
- oldformat=zxamactformat()
- oldsaveformat=zxamactsaveformat()
-
- /* what file must convert? */
- 'requestfile >t:zxamexplodetap.tmp "'zxamactloadpath()'" title "Select the .TAP file..." pattern "#?.TAP"'
- name=zxampploadfile('t:zxamexplodetap.tmp')
- name=left(name,length(name)-1) /* delete the LF */
-
- /* destination directory */
- 'requestfile >t:zxamexplodetap.tmp "'zxamactsavepath()'" drawersonly savemode'
- destdrawer=zxampploadfile('t:zxamexplodetap.tmp')
- destdrawer=strip(left(destdrawer,length(destdrawer)-1),'B','"') /* delete LF and " */
-
- if name='' then exit
-
- ZXAMEnableAbort() /* enable the Abort ARexx gadget */
-
- name=strip(left(name,pos('"',name,2)),'B','"') /* no " */
-
- /* delete the extension of filename */
- namenoext=zxamfilepart(name)
- if lastpos('.',namenoext)~=0 then namenoext=left(namenoext,lastpos('.',namenoext)-1)
-
- /* open the .TAP file */
- if ~open('fichero',name,'R') then signal cleanup
-
-
- counter=0
-
- zxamnameformat('Processing "'zxamfilepart(name)'"','Wait...')
-
- /* discompose the file */
- do forever
-
- if ZXAMReadAbort() then signal cleanup2
-
- dummy=readch('fichero',2) /* read two bytes */
- if dummy='' then signal cleanup2
-
- longblock=c2d(reverse(dummy)) /* inverted Z80 format */
-
- block=readch('fichero',longblock) /* read the data block */
-
- defext='.bytes'
-
- /* is it a header? */
- if ((longblock=19)&(left(block,1)='00'x)) then defext='.header'
-
- /* save the data */
-
- newname=namenoext''counter''defext
-
- if ~open('fichero2',zxamjoinpathname(destdrawer,newname),'W') then signal cleanup2
-
- dummy=writech('fichero2',block)
-
- dummy=close('fichero2')
-
- if ~((longblock=19)&(left(block,1)='00'x)) then counter=counter+1
-
- end
-
-
- cleanup2:
- dummy=close('fichero')
-
- cleanup:
- if oldname='' then
- zxamclearnameformat()
- else
- zxamnameformat(oldname,oldformat)
-
- zxamsaveformat(oldsaveformat)
-
- exit
-